package xiaocao.learn.designpattern.filter;

import java.util.ArrayList;
import java.util.List;

public class FilterChain implements Filter{
	private List<Filter> filters = new ArrayList<Filter>();
	public  FilterChain addFilter(Filter filter){
		filters.add(filter);
		return this;
	}
	@Override
	public String doFilter(String msg) {
		String r = msg;
		for(Filter filter:filters){
			r = filter.doFilter(r);
		}
		return r;
	}
	public List<Filter> getFilters() {
		return filters;
	}
	public void setFilters(List<Filter> filters) {
		this.filters = filters;
	}
	

}
